package cn.gs;

import cn.gs.config.BeansConfig;
import cn.gs.entity.User;
import cn.gs.service.UserServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * 基于Java配置的Bean
 * 1.配置类
 * 2.配置类中定义Bean
 * 3.配置类中定义Aspect ？
 * **/
public class Application {

    public static void main(String[] args) {
        ApplicationContext context =
                new AnnotationConfigApplicationContext(BeansConfig.class);

        UserServiceImpl userService = context.getBean("userService", UserServiceImpl.class);

        List<User> users = userService.findUserList();

        users.forEach(a->System.out.println(a.getName()+","+a.getAge()+","+a.getRemark()));
    }
}
